/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yy.bugzilla.desk;

import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.text.TextAlignment;

/**
 *
 * @author Alan
 */
public class ServerConfigPane {

    public static final String SERVER_CONFIG = "Server Config";
    private Pane contextPane;

    public Pane getContextPane() {
        if (contextPane == null) {
            contextPane = generatePane();
        }

        return contextPane;
    }

    private Pane generatePane() {


        HBox hbServerName = getServerNameHB();
        HBox hbServerURL = getServerURLHB();
        HBox hbUserName = getUserNameHB();
        HBox hbUserPassword = getUserPasswordHB();

        VBox vBox = new VBox();
        vBox.setSpacing(20);
        vBox.setAlignment(Pos.CENTER);
        vBox.getChildren().addAll(hbServerName, hbServerURL, hbUserName, hbUserPassword);

        return vBox;
    }

    private HBox getServerNameHB() {
        return getInputHBox("Server Name:", "Please input server name here.");
    }

    private HBox getServerURLHB() {
        return getInputHBox("Server URL:", "Please input server url here.");
    }

    private HBox getUserNameHB() {
        return getInputHBox("User Name:", "Please input user name here.");
    }

    private HBox getUserPasswordHB() {
        return getInputHBox("User Password:", "Please input user password here.");
    }

    private HBox getInputHBox(String label, String promptText) {
        Label lbl = new Label(label);
        lbl.setAlignment(Pos.CENTER_RIGHT);
        lbl.setPrefWidth(150);

        TextField tf = new TextField();
        tf.setPrefWidth(250);
        tf.setPromptText(promptText);
        
        HBox hb = new HBox();
        hb.setSpacing(20);
        hb.setAlignment(Pos.CENTER);
        hb.getChildren().addAll(lbl, tf);
        return hb;
    }
}
